﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Speedy
{
    public class Tools
    {
    //    #region Compression
    //    private void Zip(string SrcFile, string DstFile, int BufferSize)
    //    {
    //        FileStream fileStreamIn = new FileStream(SrcFile, FileMode.Open, FileAccess.Read);
    //        FileStream fileStreamOut = new FileStream(DstFile, FileMode.Create, FileAccess.Write);
    //        ZipOutputStream zipOutStream = new ZipOutputStream(fileStreamOut);

    //        byte[] buffer = new byte[BufferSize];

    //        ZipEntry entry = new ZipEntry(Path.GetFileName(SrcFile));
    //        zipOutStream.PutNextEntry(entry);

    //        int size;
    //        do
    //        {
    //            size = fileStreamIn.Read(buffer, 0, buffer.Length);
    //            zipOutStream.Write(buffer, 0, size);
    //        } while (size > 0);

    //        zipOutStream.Close();
    //        fileStreamOut.Close();
    //        fileStreamIn.Close();
    //    }
    //    private byte[] Zip(string SrcFile, int BufferSize)
    //    {
    //        FileStream fileStreamIn = new FileStream(SrcFile, FileMode.Open, FileAccess.Read);
    //        //FileStream fileStreamOut = new FileStream(DstFile, FileMode.Create, FileAccess.Write);
    //        MemoryStream fileStreamOut = new MemoryStream();
    //        ZipOutputStream zipOutStream = new ZipOutputStream(fileStreamOut);

    //        byte[] buffer = new byte[BufferSize];

    //        ZipEntry entry = new ZipEntry(Path.GetFileName(SrcFile));
    //        zipOutStream.PutNextEntry(entry);

    //        int size;
    //        do
    //        {
    //            size = fileStreamIn.Read(buffer, 0, buffer.Length);
    //            zipOutStream.Write(buffer, 0, size);
    //        } while (size > 0);

    //        zipOutStream.Close();
    //        fileStreamOut.Close();
    //        fileStreamIn.Close();
    //        return fileStreamOut.ToArray();
    //    }
    //    private void UnZip(string SrcFile, string DstFile, int BufferSize)
    //    {
    //        FileStream fileStreamIn = new FileStream(SrcFile, FileMode.Open, FileAccess.Read);
    //        ZipInputStream zipInStream = new ZipInputStream(fileStreamIn);
    //        ZipEntry entry = zipInStream.GetNextEntry();
    //        FileStream fileStreamOut = new FileStream(DstFile + @"\" + entry.Name, FileMode.Create, FileAccess.Write);

    //        int size;
    //        byte[] buffer = new byte[BufferSize];
    //        do
    //        {
    //            size = zipInStream.Read(buffer, 0, buffer.Length);
    //            fileStreamOut.Write(buffer, 0, size);
    //        } while (size > 0);

    //        zipInStream.Close();
    //        fileStreamOut.Close();
    //        fileStreamIn.Close();
    //    }
    //    private byte[] UnZip(string SrcFile, int BufferSize)
    //    {
    //        FileStream fileStreamIn = new FileStream(SrcFile, FileMode.Open, FileAccess.Read);
    //        ZipInputStream zipInStream = new ZipInputStream(fileStreamIn);
    //        ZipEntry entry = zipInStream.GetNextEntry();
    //        //FileStream fileStreamOut = new FileStream(DstFile + @"\" + entry.Name, FileMode.Create, FileAccess.Write);
    //        MemoryStream fileStreamOut = new MemoryStream();
    //        int size;
    //        byte[] buffer = new byte[BufferSize];
    //        do
    //        {
    //            size = zipInStream.Read(buffer, 0, buffer.Length);
    //            fileStreamOut.Write(buffer, 0, size);
    //        } while (size > 0);

    //        zipInStream.Close();
    //        fileStreamOut.Close();
    //        fileStreamIn.Close();
    //        return fileStreamOut.ToArray();
    //    }
    //    #endregion

    }
}
